-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate form verification on the backend #392
Conversation
also remove it from the client side reviews request type is optional because we still use it when displaying reviews
9152ab2
to
b983707
Compare
btw I'm not sure what other PRs open are modifying different parts of the same file, so I ignored the prettier auto-reformat file for now. I know it's not ideal, but I would rather be able to merge the other PRs (then run a larger reformat) so we can avoid merge conflicts |
That's fine. You'll need to update stacks/backend.ts to include the GRECAPTCHA_SECRET env variable. |
@js0mmer added! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't seem to get it to work on staging despite setting up the env variable. Says ReCAPTCHA token is invalid when just checking it and submitting normally.
That's strange – are you able to get it to work locally and/or did you redeploy after changing the env vars? |
or maybe from Google Recaptcha manage page you need to allow it to be on any |
Actually I see, there's one more spot you need to add the env variable, in the build-and-deploy workflow under the .github folder. |
Alright cool found that and one more spot where there were env vars. Hopefully it is correct now |
For some reason it still doesn't seem to work – is it in the GitHub repo secrets? |
The catch statement doesn't include instances where tokens are invalid, so that's why it didn't log. (the request itself didn't fail, it's just that the |
2cc52e8
to
098dab6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works on staging and locally! See additional comments.
Co-authored-by: Jacob Sommer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple more areas with ||
. Other than that, looks good.
Co-authored-by: Jacob Sommer <[email protected]>
Co-authored-by: Jacob Sommer <[email protected]>
Deployed staging instance to https://staging-392.peterportal.org |
Description (basically the commit history)
/reviews
ReviewData
(kinda just slapped this intotypes.d.ts
for now as we will want to refactor this anyways once we have zod and/or mongoose to validate items going into a database)Screenshots
Mostly backend validation, but we alert the API-provided error if it exists:
Steps to verify/test this change:
GRECAPTCHA_SECRET=<recaptcha_secret_here>
/reviews
, copy as fetchcaptchaToken
is omitted form the request bodyverified: true
. It should still show up in reviews to verify. This is less important because we will be validating the entire form body in the near future (Zod or mongoose).Final Checks:
(optional)
Issues
Closes #381